<template>
  <div class="addTeam">
    <div class="header">
      <div class="itme" @click="cancel">取消</div>
      <div class="itme">选择联系人</div>
      <div class="itme btnBox">
        <div class="btn" @click="finish">完成({{pitch_on_number}})</div>
      </div>
    </div>
    <div class="content">
      <div class="ss">
        <mt-search v-model="value" cancel-text="取消" placeholder="搜索"></mt-search>
      </div>
      <ul>
        <li v-for="(item,index) in arr" :key="index">
          <div
            class="pitchOn"
            :class="item.isPitchOn?'pitchOn_yes':'pitchOn_no'"
            @click="pitch_on(item)"
          ></div>
          <div class="icon">
            <img :src="item.img" alt>
          </div>
          <div class="name">{{item.name}}</div>
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
import { send, addTeam } from "../../im";
export default {
  data() {
    return {
      MC: "",
      value: "",
      arr: [
        {
          img: require("../../assets/imgBTC/ps.png"),
          isPitchOn: false,
          name: "静香",
          id: 1
        },
        {
          img: require("../../assets/imgBTC/ps.png"),
          isPitchOn: false,
          name: "胖虎",
          id: 2
        }
      ]
    };
  },
  computed: {
    pitch_on_number() {
      let n = 0;
      this.arr.filter(o => {
        if (o.isPitchOn) {
          n++;
        }
      });
      console.log(n);
      return n;
    }
  },
  mounted() {},
  methods: {
    pitch_on(item) {
      item.isPitchOn = !item.isPitchOn;
    },
    add() {
      addTeam(this.MC, function(obj) {
        console.log("你创建了一个群", obj);
      });
    },
    finish() {
      this.$router.push({
        path: "/coze",
        query: { item: JSON.stringify(this.arr[1]) }
      });
    },
    cancel() {
      this.$router.go(-1);
    }
  },
  components: {}
};
</script>
<style lang="stylus" scoped>
.addTeam {
  width: 100%;
  height: 100%;
  background: #fff;

  .header {
    display: flex;
    line-height: 1.2rem;
    background: #F4F2F2;
    padding: 0 0.2rem;

    .itme {
      flex: 1;
    }

    .btnBox {
      .btn {
        background: #3399FF;
        color: #fff;
        min-width: 1.12rem;
        height: 0.63rem;
        line-height: 0.63rem;
        opacity: 0.62;
        border-radius: 6px;
        text-align: center;
        float: right;
        margin-top: 14px;
        font-size: 13px;
        padding: 0 0.1rem;
      }
    }
  }

  .content {
    .ss {
      height: 1rem;
    }

    ul {
      li {
        display: flex;
        margin: 0.2rem 0 0.2rem 0.2rem;

        .pitchOn {
          width: 0.48rem;
          height: 0.48rem;
          border-radius: 50%;
          margin-right: 0.2rem;
          margin-top: 0.1rem;
        }

        .pitchOn_no {
          border: 1px solid rgba(182, 182, 182, 1);
        }

        .pitchOn_yes {
          background: #3399FF;
        }

        .icon {
          width: 0.72rem;
          height: 0.72rem;

          img {
            width: 100%;
            height: 100%;
          }
        }

        .name {
          flex: 1;
          line-height: 0.8rem;
          border-bottom: 1px solid #EBEBEB;
          padding-left: 0.2rem;
          color: #0D0D0D;
        }
      }
    }
  }
}
</style>